﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.LibrarySys
{
    public class T_PUB_SCRAP
    {
        private readonly DALL.LibrarySys.T_PUB_SCRAP dal = new DALL.LibrarySys.T_PUB_SCRAP();
        public T_PUB_SCRAP()
        { }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetApplyList(int uid, int bid, string titel, int state, DateTime begintime, DateTime endtime, string flag)
        {
            string strWhere = "";
            if (uid != -1)
            {
                strWhere += string.Format(" and APPLICANT = {0}", uid);
            }
            if (bid != -1)
            {
                strWhere += string.Format(" and a.BRANCH_ID = {0}", bid);
            }
            if (!string.IsNullOrEmpty(titel))
            {
                strWhere += string.Format(" and TITEL like '%{0}%'", titel);
            }
            if (flag == "2")
            {
                strWhere += string.Format(" and FLAG='{0}'", flag);
            }
            else
            {
                strWhere += string.Format(" and FLAG<>'2'");
            }
            if (state != 0)
            {
                strWhere += string.Format(" and STATE='{0}'", state);
            }
            if (!string.IsNullOrEmpty(begintime.ToString()))
            {
                strWhere += string.Format(" and APPLY_TIME >= '{0}' ", begintime);
            }
            if (!string.IsNullOrEmpty(endtime.ToString()))
            {
                strWhere += string.Format(" and APPLY_TIME <= '{0}' ", endtime);
            }
            DataSet ds = dal.GetApplyList(strWhere);
            return ds;
        }

        /// <summary>
        /// 获取报修智能提示
        /// </summary>
        /// <param name="branch_id"></param>
        /// <returns></returns>
        public DataSet GetRepairApplyTitel(int branch_id)
        {
            return dal.GetRepairApplyTitel(branch_id);
        }

        public DataSet GetRepairApplyTitel()
        {
            return dal.GetRepairApplyTitel();
        }

        /// <summary>
        /// 获取报废智能提示
        /// </summary>
        /// <param name="branch_id"></param>
        /// <returns></returns>
        public DataSet GetScrapApplyTitel(int branch_id)
        {
            return dal.GetScrapApplyTitel(branch_id);
        }

        public DataSet GetScrapApplyTitel()
        {
            return dal.GetScrapApplyTitel();
        }

        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.LibrarySys.T_PUB_SCRAP model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.LibrarySys.T_PUB_SCRAP model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void UpdateLibraryMaterial(Model.LibrarySys.T_PUB_SCRAP model, Model.LibrarySys.T_PUB_LIBRARYMATERIAL lmmodel)
        {
            dal.UpdateLibraryMaterial(model, lmmodel);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            return dal.Delete(ID);
        }
        

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.LibrarySys.T_PUB_SCRAP GetModel(int ID)
        {

            return dal.GetModel(ID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.LibrarySys.T_PUB_SCRAP> GetModelList(string strWhere)
        {
            return dal.GetListArray(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  Method
    }
}
